
angular.module('information.controller', ['information.service'])
    .controller("informationCtrl", function ($scope, $ionicModal,$http,$rootScope) {

        var one=null,two=null,
           CCSessionId =localStorage.getItem("CCSessionId");


        var port0='/authority/base-dictionary.json?';
        var port2='/account/bank.json?';

        var url0=$rootScope.myglobal.serverurl+port0+"CCSessionId="+CCSessionId;
        var url1=url0;
        var url2=$rootScope.myglobal.serverurl+port2+"CCSessionId="+CCSessionId;
            //获取银行信息
        $scope.choose=function(a){
            if(a===1){
                console.log(a);
                $scope.choosestyle='选择银行';
                $http.get(url0+ '&categoryCode=BANKTYPE&subCategoryCode=MAINTYPE')
                    .success(function(data2){
                        console.log(data2);
                        $scope.clientSideList=data2
                    })
                $scope.createContact = function(a) {
                    $scope.modal.hide();
                    // 将信息反馈到银行信息框中
                    $scope.blankchoose= a.itemValue;
                    one=a.itemCode
                };
            }else if(a===2){
                $scope.choosestyle='选择支付地';
                $http.get(url1+ '&categoryCode=CCPC&subCategoryCode=PROVINCE')
                    .success(function(data2){
                        console.log(data2);
                        $scope.clientSideList=data2

                    })
                $scope.createContact = function(a) {
                    $scope.modal.hide();

                    $scope.areachoose= a.itemCode;
                   two=a.itemValue
                };
            }


        }
      //获取开户银行列表
      $scope.obtain=function(){
          console.log(one,two);
          if(one===null||two===null){
              alert('银行信息和支付信息不能为空')
              return
          }

          $http.post(url2+ '&ccpcCode='+two+'&bankType='+one)
              .success(function(data2){

                  console.log(data2);
                  $scope.arrs=data2;

              })
      }
        //点击模板出现或隐藏
        $ionicModal.fromTemplateUrl('templates/information.html', {
            scope: $scope
        }).then(function(modal) {
            $scope.modal = modal;

        });

    //

    })



